const express = require("express");
const bodyParser = require("body-parser");
const { expressjwt } = require("express-jwt"); //校验token的模块
let app = express();
app.use(bodyParser.urlencoded({ extended: false }));
app.use(bodyParser.json());
app.use(express.static("static")); // 加载静态文件

//unless是指哪些接口不需要校验
app.use(
  expressjwt({ secret: "mytoken", algorithms: ["HS256"] }).unless({
    path: [/\.png$/, "/checkuser"],
  })
);
//引入用户路由
let userRouter = require("./routers/userRouter");
app.use("/user", userRouter); // express里的二级路由

//引入登录路由
let loginRouter = require("./routers/loginRouter");
app.use(loginRouter); //一级路由不需要加前缀 /user

// 引入广告路由;
let advRouter = require("./routers/advRouter");
app.use("/adv", advRouter);
app.listen(8888);
